```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>深入理解哈希表 | 数据结构可视化</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background-color: #f8fafc;
            color: #1e293b;
            line-height: 1.6;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 50%, #9333ea 100%);
        }
        .card-hover {
            transition: all 0.3s ease;
        }
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
        }
        .section-divider {
            position: relative;
            height: 80px;
            overflow: hidden;
        }
        .section-divider svg {
            position: absolute;
            bottom: 0;
            left: 0;
            width: 100%;
            height: 100%;
        }
        .drop-cap::first-letter {
            float: left;
            font-size: 4rem;
            line-height: 0.7;
            margin: 0.15em 0.1em 0 0;
            color: #4f46e5;
            font-weight: 700;
        }
        .highlight-box {
            background: linear-gradient(90deg, rgba(79, 70, 229, 0.1) 0%, rgba(124, 58, 237, 0.05) 100%);
            border-left: 4px solid #4f46e5;
        }
        .animate-float {
            animation: float 6s ease-in-out infinite;
        }
        @keyframes float {
            0%, 100% { transform: translateY(0); }
            50% { transform: translateY(-10px); }
        }
        .code-block {
            font-family: 'Courier New', Courier, monospace;
            background-color: #1e293b;
            color: #e2e8f0;
            border-radius: 0.5rem;
        }
    </style>
</head>
<body>
    <!-- Hero Section -->
    <section class="hero-gradient text-white min-h-screen flex items-center relative overflow-hidden">
        <div class="absolute inset-0 opacity-20" style="background-image: url('');"></div>
        <div class="container mx-auto px-6 z-10">
            <div class="flex flex-col lg:flex-row items-center justify-between">
                <div class="lg:w-1/2 mb-12 lg:mb-0">
                    <h1 class="text-4xl md:text-6xl font-bold mb-6 font-serif">深入理解<span class="text-indigo-200">哈希表</span></h1>
                    <p class="text-xl md:text-2xl text-indigo-100 mb-8">探索现代数据结构的高效存储方案</p>
                    <p class="text-lg text-indigo-50 mb-8 max-w-lg">
                        哈希表是一种通过哈希函数将键映射到存储位置的数据结构，提供了接近常数时间的查找、插入和删除操作。它广泛应用于编程语言内置数据结构、数据库索引和缓存系统等领域。
                    </p>
                    <div class="flex space-x-4">
                        <a href="#basics" class="px-6 py-3 bg-white text-indigo-600 font-medium rounded-full shadow-lg hover:bg-indigo-50 transition duration-300">
                            <i class="fas fa-book-open mr-2"></i>开始学习
                        </a>
                        <a href="#visualization" class="px-6 py-3 bg-transparent border-2 border-white text-white font-medium rounded-full hover:bg-white hover:text-indigo-600 transition duration-300">
                            <i class="fas fa-project-diagram mr-2"></i>可视化
                        </a>
                    </div>
                </div>
                <div class="lg:w-1/2 relative">
                    <div class="relative w-full max-w-lg">
                        <div class="absolute top-0 left-0 w-64 h-64 bg-indigo-300 rounded-full mix-blend-multiply filter blur-xl opacity-50 animate-float"></div>
                        <div class="absolute top-0 right-0 w-64 h-64 bg-purple-300 rounded-full mix-blend-multiply filter blur-xl opacity-50 animate-float" style="animation-delay: 1s;"></div>
                        <div class="absolute bottom-0 left-1/2 w-64 h-64 bg-pink-300 rounded-full mix-blend-multiply filter blur-xl opacity-50 animate-float" style="animation-delay: 2s;"></div>
                    </div>
                    <div class="relative bg-white rounded-2xl shadow-2xl overflow-hidden w-full max-w-md mx-auto">
                        <div class="p-6">
                            <div class="flex items-center mb-4">
                                <div class="w-3 h-3 rounded-full bg-red-500 mr-2"></div>
                                <div class="w-3 h-3 rounded-full bg-yellow-500 mr-2"></div>
                                <div class="w-3 h-3 rounded-full bg-green-500"></div>
                            </div>
                            <pre class="code-block p-4 text-sm overflow-x-auto">
<span class="text-purple-400">class</span> <span class="text-blue-400">HashTable</span> {
    <span class="text-purple-400">constructor</span>() {
        <span class="text-blue-400">this</span>.<span class="text-green-400">size</span> = <span class="text-orange-400">16</span>;
        <span class="text-blue-400">this</span>.<span class="text-green-400">buckets</span> = <span class="text-blue-400">Array</span>(<span class="text-blue-400">this</span>.<span class="text-green-400">size</span>).<span class="text-purple-400">fill</span>(<span class="text-orange-400">null</span>);
    }

    <span class="text-purple-400">hash</span>(<span class="text-green-400">key</span>) {
        <span class="text-purple-400">let</span> hash = <span class="text-orange-400">0</span>;
        <span class="text-purple-400">for</span> (<span class="text-purple-400">let</span> i = <span class="text-orange-400">0</span>; i < key.<span class="text-green-400">length</span>; i++) {
            hash = (hash + key.<span class="text-purple-400">charCodeAt</span>(i)) % <span class="text-blue-400">this</span>.<span class="text-green-400">size</span>;
        }
        <span class="text-purple-400">return</span> hash;
    }
}</pre>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Basics Section -->
    <section id="basics" class="py-20 bg-white">
        <div class="container mx-auto px-6">
            <div class="text-center mb-16">
                <h2 class="text-3xl md:text-4xl font-bold mb-4 font-serif">哈希表基础概念</h2>
                <div class="w-24 h-1 bg-indigo-600 mx-auto"></div>
            </div>

            <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8">
                <!-- Card 1: Hash Function -->
                <div class="bg-white rounded-xl shadow-lg overflow-hidden card-hover">
                    <div class="h-2 bg-indigo-500"></div>
                    <div class="p-6">
                        <div class="flex items-center mb-4">
                            <div class="w-12 h-12 rounded-full bg-indigo-100 flex items-center justify-center mr-4">
                                <i class="fas fa-fingerprint text-indigo-600 text-xl"></i>
                            </div>
                            <h3 class="text-xl font-bold">哈希函数</h3>
                        </div>
                        <p class="text-slate-600 mb-4">将键(key)映射到哈希表中的一个位置(索引)，决定了数据存储的位置。</p>
                        <div class="highlight-box p-4 rounded-lg mb-4">
                            <p class="font-medium text-indigo-700">关键性质：</p>
                            <ul class="list-disc pl-5 text-slate-700">
                                <li>应尽可能均匀地分布键</li>
                                <li>减少冲突(不同键映射到同一位置)</li>
                                <li>计算速度快</li>
                            </ul>
                        </div>
                    </div>
                </div>

                <!-- Card 2: Hash Bucket -->
                <div class="bg-white rounded-xl shadow-lg overflow-hidden card-hover">
                    <div class="h-2 bg-purple-500"></div>
                    <div class="p-6">
                        <div class="flex items-center mb-4">
                            <div class="w-12 h-12 rounded-full bg-purple-100 flex items-center justify-center mr-4">
                                <i class="fas fa-boxes text-purple-600 text-xl"></i>
                            </div>
                            <h3 class="text-xl font-bold">哈希桶</h3>
                        </div>
                        <p class="text-slate-600 mb-4">哈希表的数组或列表，每个桶可以存储一个或多个键值对。</p>
                        <div class="highlight-box p-4 rounded-lg mb-4">
                            <p class="font-medium text-purple-700">典型实现：</p>
                            <ul class="list-disc pl-5 text-slate-700">
                                <li>通常使用数组实现</li>
                                <li>每个元素(桶)可能是链表或其他结构</li>
                                <li>桶数量影响哈希表性能</li>
                            </ul>
                        </div>
                    </div>
                </div>

                <!-- Card 3: Load Factor -->
                <div class="bg-white rounded-xl shadow-lg overflow-hidden card-hover">
                    <div class="h-2 bg-pink-500"></div>
                    <div class="p-6">
                        <div class="flex items-center mb-4">
                            <div class="w-12 h-12 rounded-full bg-pink-100 flex items-center justify-center mr-4">
                                <i class="fas fa-balance-scale-right text-pink-600 text-xl"></i>
                            </div>
                            <h3 class="text-xl font-bold">负载因子</h3>
                        </div>
                        <p class="text-slate-600 mb-4">哈希表中元素的数量与桶的数量之比，影响性能的关键指标。</p>
                        <div class="highlight-box p-4 rounded-lg">
                            <p class="font-medium text-pink-700">性能影响：</p>
                            <ul class="list-disc pl-5 text-slate-700">
                                <li>较高负载因子导致更多冲突</li>
                                <li>通常设置阈值(如0.75)</li>
                                <li>超过阈值会触发扩容</li>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Divider -->
    <div class="section-divider bg-white">
        <svg viewBox="0 0 1200 120" preserveAspectRatio="none">
            <path d="M0,0V46.29c47.79,22.2,103.59,32.17,158,28,70.36-5.37,136.33-33.31,206.8-37.5C438.64,32.43,512.34,53.67,583,72.05c69.27,18,138.3,24.88,209.4,13.08,36.15-6,69.85-17.84,104.45-29.34C989.49,25,1113-14.29,1200,52.47V0Z" opacity=".25" fill="#4f46e5"></path>
            <path d="M0,0V15.81C13,36.92,27.64,56.86,47.69,72.05,99.41,111.27,165,111,224.58,91.58c31.15-10.15,60.09-26.07,89.67-39.8,40.92-19,84.73-46,130.83-49.67,36.26-2.85,70.9,9.42,98.6,31.56,31.77,25.39,62.32,62,103.63,73,40.44,10.79,81.35-6.69,119.13-24.28s75.16-39,116.92-43.05c59.73-5.85,113.28,22.88,168.9,38.84,30.2,8.66,59,6.17,87.09-7.5,22.43-10.89,48-26.93,60.65-49.24V0Z" opacity=".5" fill="#4f46e5"></path>
            <path d="M0,0V5.63C149.93,59,314.09,71.32,475.83,42.57c43-7.64,84.23-20.12,127.61-26.46,59-8.63,112.48,12.24,165.56,35.4C827.93,77.22,886,95.24,951.2,90c86.53-7,172.46-45.71,248.8-84.81V0Z" fill="#4f46e5"></path>
        </svg>
    </div>

    <!-- Collision Handling Section -->
    <section class="py-20 bg-indigo-50">
        <div class="container mx-auto px-6">
            <div class="text-center mb-16">
                <h2 class="text-3xl md:text-4xl font-bold mb-4 font-serif">冲突解决策略</h2>
                <div class="w-24 h-1 bg-indigo-600 mx-auto"></div>
                <p class="text-xl text-slate-600 mt-6 max-w-2xl mx-auto">哈希冲突是不可避免的，关键在于如何高效处理</p>
            </div>

            <div class="flex flex-col lg:flex-row gap-12 items-center mb-16">
                <div class="lg:w-1/2">
                    <h3 class="text-2xl font-bold mb-6 flex items-center">
                        <span class="w-10 h-10 rounded-full bg-indigo-600 text-white flex items-center justify-center mr-4">1</span>
                        链表法 (Separate Chaining)
                    </h3>
                    <p class="text-slate-700 mb-4 drop-cap">当多个键映射到同一哈希桶时，使用链表存储这些键值对。这是最常用的冲突解决方法之一，实现简单且在实践中表现良好。</p>
                    <div class="bg-white p-6 rounded-lg shadow-md mb-6">
                        <h4 class="font-bold text-lg mb-3 text-indigo-700 flex items-center">
                            <i class="fas fa-link mr-2"></i>链表节点结构
                        </h4>
                        <ul class="list-disc pl-5 text-slate-700 space-y-2">
                            <li>每个节点存储一个键值对</li>
                            <li>包含对下一个节点的引用</li>
                            <li>新节点通常插入链表头部</li>
                            <li>查找需要遍历链表</li>
                        </ul>
                    </div>
                    <div class="highlight-box p-6 rounded-lg">
                        <h4 class="font-bold text-lg mb-3 text-purple-700 flex items-center">
                            <i class="fas fa-star mr-2"></i>Java的HashMap实现
                        </h4>
                        <p class="text-slate-700">Java 8之前使用纯链表，Java 8后当链表长度超过阈值(8)时转为红黑树，将最坏情况时间复杂度从O(n)降低到O(log n)。</p>
                    </div>
                </div>
                <div class="lg:w-1/2">
                    <div class="mermaid bg-white p-6 rounded-lg shadow-lg">
                        graph LR
                            A[哈希表数组] --> B[索引0: null]
                            A --> C[索引1: 链表头]
                            C --> D[{"键: 'apple', 值: 1"}]
                            D --> E[{"键: 'pear', 值: 2"}]
                            E --> F[null]
                            A --> G[索引2: null]
                            A --> H[索引3: 链表头]
                            H --> I[{"键: 'banana', 值: 3"}]
                            I --> J[null]
                    </div>
                </div>
            </div>

            <div class="flex flex-col lg:flex-row-reverse gap-12 items-center">
                <div class="lg:w-1/2">
                    <h3 class="text-2xl font-bold mb-6 flex items-center">
                        <span class="w-10 h-10 rounded-full bg-purple-600 text-white flex items-center justify-center mr-4">2</span>
                        开放地址法 (Open Addressing)
                    </h3>
                    <p class="text-slate-700 mb-4">当发生冲突时，寻找哈希表中的下一个可用位置存储键值对。这种方法完全避免了链表的使用，所有数据都存储在数组本身中。</p>
                    
                    <div class="grid grid-cols-1 md:grid-cols-3 gap-4 mb-6">
                        <div class="bg-white p-4 rounded-lg shadow">
                            <h4 class="font-bold text-purple-700 mb-2 flex items-center">
                                <i class="fas fa-arrow-right mr-2"></i>线性探测
                            </h4>
                            <p class="text-sm text-slate-700">固定步长(如1)寻找下个位置</p>
                        </div>
                        <div class="bg-white p-4 rounded-lg shadow">
                            <h4 class="font-bold text-purple-700 mb-2 flex items-center">
                                <i class="fas fa-project-diagram mr-2"></i>二次探测
                            </h4>
                            <p class="text-sm text-slate-700">步长按二次函数增长</p>
                        </div>
                        <div class="bg-white p-4 rounded-lg shadow">
                            <h4 class="font-bold text-purple-700 mb-2 flex items-center">
                                <i class="fas fa-random mr-2"></i>双重哈希
                            </h4>
                            <p class="text-sm text-slate-700">使用第二个哈希函数</p>
                        </div>
                    </div>
                    
                    <div class="highlight-box p-6 rounded-lg">
                        <h4 class="font-bold text-lg mb-3 text-pink-700 flex items-center">
                            <i class="fab fa-python mr-2"></i>Python的dict实现
                        </h4>
                        <p class="text-slate-700">Python的字典使用开放地址法(伪随机探测)，结合了高度优化的哈希函数，使其成为Python中最快的数据结构之一。</p>
                    </div>
                </div>
                <div class="lg:w-1/2">
                    <div class="mermaid bg-white p-6 rounded-lg shadow-lg">
                        graph LR
                            A[哈希表数组] --> B[索引0: null]
                            A --> C[索引1: 'apple'=1]
                            A --> D[索引2: 'pear'=2]
                            A --> E[索引3: 'banana'=3]
                            A --> F[索引4: null]
                            style C fill:#d9f99d,stroke:#333
                            style D fill:#d9f99d,stroke:#333
                            style E fill:#d9f99d,stroke:#333
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Performance Section -->
    <section id="visualization" class="py-20 bg-white">
        <div class="container mx-auto px-6">
            <div class="text-center mb-16">
                <h2 class="text-3xl md:text-4xl font-bold mb-4 font-serif">哈希表性能分析</h2>
                <div class="w-24 h-1 bg-indigo-600 mx-auto"></div>
                <p class="text-xl text-slate-600 mt-6 max-w-2xl mx-auto">理解影响哈希表性能的关键因素</p>
            </div>

            <div class="grid grid-cols-1 lg:grid-cols-2 gap-12 mb-16">
                <div>
                    <h3 class="text-2xl font-bold mb-6 flex items-center">
                        <i class="fas fa-stopwatch text-indigo-600 mr-4 text-3xl"></i>
                        时间复杂度分析
                    </h3>
                    <div class="bg-indigo-50 p-6 rounded-xl">
                        <div class="overflow-x-auto">
                            <table class="w-full text-left">
                                <thead>
                                    <tr class="border-b border-indigo-200">
                                        <th class="pb-3 font-bold text-indigo-800">操作</th>
                                        <th class="pb-3 font-bold text-indigo-800">平均情况</th>
                                        <th class="pb-3 font-bold text-indigo-800">最坏情况</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <tr class="border-b border-indigo-100">
                                        <td class="py-3 font-medium">查找</td>
                                        <td class="py-3">O(1)</td>
                                        <td class="py-3">O(n)</td>
                                    </tr>
                                    <tr class="border-b border-indigo-100">
                                        <td class="py-3 font-medium">插入</td>
                                        <td class="py-3">O(1)</td>
                                        <td class="py-3">O(n)</td>
                                    </tr>
                                    <tr>
                                        <td class="py-3 font-medium">删除</td>
                                        <td class="py-3">O(1)</td>
                                        <td class="py-3">O(n)</td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>
                    <div class="mt-6 bg-white p-6 rounded-xl shadow-md">
                        <h4 class="font-bold text-lg mb-3 text-indigo-700">影响性能的因素</h4>
                        <ul class="list-disc pl-5 text-slate-700 space-y-2">
                            <li><span class="font-medium">哈希函数质量</span> - 均匀性越好，性能越高</li>
                            <li><span class="font-medium">负载因子</span> - 通常保持在0.7以下</li>
                            <li><span class="font-medium">冲突解决策略</span> - 影响实际查找路径长度</li>
                            <li><span class="font-medium">扩容策略</span> - 影响插入操作的平摊成本</li>
                        </ul>
                    </div>
                </div>

                <div>
                    <h3 class="text-2xl font-bold mb-6 flex items-center">
                        <i class="fas fa-expand-arrows-alt text-purple-600 mr-4 text-3xl"></i>
                        扩容与再哈希
                    </h3>
                    <div class="bg-white p-6 rounded-xl shadow-md mb-6">
                        <p class="text-slate-700 mb-4">当负载因子超过阈值时，哈希表需要进行扩容以维持性能。扩容通常涉及创建一个更大的数组，并将所有现有元素重新插入(再哈希)。</p>
                        
                        <div class="mermaid">
                            flowchart TD
                                A[检查负载因子] --> B{是否超过阈值?}
                                B -->|是| C[创建更大的数组]
                                C --> D[遍历旧数组所有元素]
                                D --> E[对新数组重新计算哈希]
                                E --> F[插入到新位置]
                                B -->|否| G[继续正常操作]
                        </div>
                    </div>
                    <div class="highlight-box p-6 rounded-lg">
                        <h4 class="font-bold text-lg mb-3 text-purple-700">扩容策略</h4>
                        <ul class="list-disc pl-5 text-slate-700">
                            <li>通常扩容为原大小的2倍</li>
                            <li>Java HashMap默认初始容量16，负载因子0.75</li>
                            <li>Python dict初始容量8，扩容时至少增加1/8</li>
                            <li>再哈希可能是昂贵操作，但平摊后仍是O(1)</li>
                        </ul>
                    </div>
                </div>
            </div>

            <div class="bg-indigo-50 rounded-2xl overflow-hidden">
                <div class="p-8 md:p-12">
                    <h3 class="text-2xl md:text-3xl font-bold mb-6 text-center">实际应用中的哈希表</h3>
                    <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6">
                        <div class="bg-white p-6 rounded-lg shadow-sm text-center">
                            <div class="w-16 h-16 bg-indigo-100 rounded-full flex items-center justify-center mx-auto mb-4">
                                <i class="fab fa-java text-indigo-600 text-2xl"></i>
                            </div>
                            <h4 class="font-bold mb-2">Java HashMap</h4>
                            <p class="text-sm text-slate-600">链表+红黑树，负载因子0.75</p>
                        </div>
                        <div class="bg-white p-6 rounded-lg shadow-sm text-center">
                            <div class="w-16 h-16 bg-purple-100 rounded-full flex items-center justify-center mx-auto mb-4">
                                <i class="fab fa-python text-purple-600 text-2xl"></i>
                            </div>
                            <h4 class="font-bold mb-2">Python dict</h4>
                            <p class="text-sm text-slate-600">开放地址法，伪随机探测</p>
                        </div>
                        <div class="bg-white p-6 rounded-lg shadow-sm text-center">
                            <div class="w-16 h-16 bg-pink-100 rounded-full flex items-center justify-center mx-auto mb-4">
                                <i class="fas fa-database text-pink-600 text-2xl"></i>
                            </div>
                            <h4 class="font-bold mb-2">数据库索引</h4>
                            <p class="text-sm text-slate-600">哈希索引加速查询</p>
                        </div>
                        <div class="bg-white p-6 rounded-lg shadow-sm text-center">
                            <div class="w-16 h-16 bg-amber-100 rounded-full flex items-center justify-center mx-auto mb-4">
                                <i class="fas fa-memory text-amber-600 text-2xl"></i>
                            </div>
                            <h4 class="font-bold mb-2">缓存系统</h4>
                            <p class="text-sm text-slate-600">如Redis, Memcached</p>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true,
                curve: 'basis'
            }
        });
    </script>
</body>
</html>
```